The functions found in this section are only for use with sprites that have been imported from a skeletal animation file (like the JSON files that Spine exports) and can be used to get information about an animation asset in your game, as well as for setting certain properties within an animation. These functions can to be used along with the regular sprite functions and variables, permitting you to (for example) mix two skeleton animations using these special functions while setting the image scale using the normal sprite instance variables. For more information on the sprite instance variables see the section on Instance Variables.
The following functions are all related to controlling the skeleton animations:
These functions can be used to get and change the skin that a skeleton sprite is using:
The following set of functions are specific to the attachments that a skeleton animation sprite can use:
These functions can be used to get the current state of the bone data and state for a skeleton animation, as well as to set the bone data and state:
These functions can be used to get get the slot data for a sprite as well as manipulate its colour:
The following functions can be used to get various different sets of data about a skeleton animation sprite:
You can also use various draw routines designed specifically for
these types of sprite (apart from the regular
draw_sprite() functions). These functions give you more
control over what is being drawn and permit you to change animation
specific features, such as timing and skins:
This feature allows the dark areas of Spine sprite slots to be tinted differently to the light areas (this is a Spine IDE feature, see the Tint black section here more details). Currently, in order to make use of this feature in GameMaker Studio 2, you are required to use a custom shader when drawing a spine sprite that uses it. This shader contains a global uniform variable called "gm_SpineTintBlackColour" which the runner fills with the current tint-black colour, retrieved from the Spine data automatically. The shader required is shown below:
The Vertex Shader (this is the same as the default passthrough vertex shader)
attribute vec3 in_Position; // (x,y,z)
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y,
in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] *
object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
The Fragment Shader:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec4 gm_SpineTintBlackColour; // This is the uniform
containing the tint-black colour
void main()
{
vec4 tb = gm_SpineTintBlackColour;
vec4 texcol = texture2D( gm_BaseTexture, v_vTexcoord );
vec4 outcol;
outcol.rgb = v_vColour.rgb * texcol.rgb;
outcol.rgb += tb.rgb * ((tb.a * (texcol.a - 1.0)) + (1.0 -
texcol.rgb)); // This line performs the tint-black blending
logic
outcol.a = v_vColour.a * texcol.a;
gl_FragColor = outcol;
}
You would use this by first calling the shader, then drawing the
sprite, then resetting the shader, something like this:
shader_set(shd_spine_tint_black);
draw_self();
shader_reset();